//
//  DSZTJXQViewController.m
//  7.13苏宁框架
//
//  Created by app15 on 15/7/23.
//  Copyright (c) 2015年 lovena. All rights reserved.
//

#import "DSZTJXQViewController.h"
#import "DSZTJShowModel.h"
#import "DSZTJGroupModel.h"
#import "DSZShowViewController.h"
#import "DSZTJXQTableViewCell.h"
#import "DSZTJXQHeaderView.h"
#import "MJExtension.h"
#import "UIImageView+WebCache.h"

DSZTJShowModel *TJXQModel;
DSZTJGroupModel *TJXQgroupModel;
@interface DSZTJXQViewController ()<UITableViewDataSource,UITableViewDelegate>
{
    UITableView *table;
    NSInteger commentNum;
}
@end

@implementation DSZTJXQViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadNa];
    self.title=@"详情";
    NSDictionary *dic=[TJXQModel keyValues];
    NSArray *array=dic[@"comment"];
    commentNum=array.count;
    table=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320, 533)];
    
    [self.view addSubview:table];
    table.delegate=self;
    table.dataSource=self;
    DSZTJXQHeaderView *view=[DSZTJXQHeaderView HeaderWithNib];
    view.frame=CGRectMake(0, 0, 320, 60);
    
    [view.imaeView setImageWithURL:[NSURL URLWithString:TJXQgroupModel.image]];
    view.titleView.text=TJXQgroupModel.name;
    view.intorLabel.text=TJXQgroupModel.intor;
    table.tableHeaderView=view;
    
    
    // Do any additional setup after loading the view.
}

-(void)loadNa{
    UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 20, 44)];
    UIButton *button=[UIButton buttonWithType:UIButtonTypeSystem];
    button=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 25, 40)];
    [button setImage:[UIImage imageNamed:@"back_black_icon"]  forState:UIControlStateNormal];
    [button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:button];
    UIBarButtonItem *barbutton=[[UIBarButtonItem alloc]initWithCustomView:view];
    self.navigationItem.leftBarButtonItem=barbutton;
    
}

-(void)back{
    DSZShowViewController *view=(DSZShowViewController*)self.tabBarController;
    [view hiddenShowTabbar:NO];
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)viewWillAppear:(BOOL)animated{
    DSZShowViewController *show=(DSZShowViewController*)self.tabBarController;
    [show hiddenShowTabbar:YES];
}

-(void)Drgroupmode: (DSZTJGroupModel*)groupmodel show:(DSZTJShowModel*)model{
    TJXQgroupModel=groupmodel;
    TJXQModel=model;

}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
   static NSString *ID=@"cell";
    DSZTJXQTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];
    if (cell==nil) {
        cell=[[DSZTJXQTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    
    [cell cellmodel:TJXQModel number:commentNum];
    [cell.ContentImageView setImageWithURL:[NSURL URLWithString:TJXQModel.image]];
    cell.labelNum.text=[NSString stringWithFormat:@"全部评论(%i)",commentNum];
    cell.Titlelabel.text=TJXQModel.title;
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 559+44*commentNum;
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
